package com.lehecai.core.lottery.fetcher.lotterydraw.impl.worker;

import com.lehecai.core.lottery.LotteryType;
import org.apache.commons.lang.StringUtils;

import java.util.Calendar;

/**
 * Created by zhangzq on 14-8-11.
 */
public class LotteryDrawFetch560Worker163 extends FrequentLotteryDrawFetchWorker163 {

    public LotteryDrawFetch560Worker163(LotteryType lotteryType) {
        super(lotteryType);
    }

    @Override
    protected String getResultDetailUrl(String phase) {
        //传入的彩期为 140926051 需要转换成21040926
        String detailUrl;
        if (StringUtils.isEmpty(phase)) {
            detailUrl = historyUrlMap.get(this.getLotteryType());
        } else {
            Calendar calendar= Calendar.getInstance();
            int year = calendar.get(Calendar.YEAR);
            String yearStr = year + "";
            if (phase.length() == 9) {
                phase = phase.substring(2,6);
                phase = yearStr + phase;
            }
            detailUrl = historyUrlMap.get(this.getLotteryType()) + "?gameEn=kuai3&date=" + phase;
        }
        return detailUrl;
    }

    @Override
    public String getResultAttribute() {
        return "data-win-number";
    }
}
